﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LinQ_DTO;

namespace DAO
{
    public class ChamDiemDAO
    {
        public List<shop_chamdiem> LayTatCaChamDiem()
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var List = from c in EFashionDB.shop_chamdiems select c;
            return List.ToList();
        }




        public List<shop_chamdiem> LayChamDiemCuaMotSanPham(int MaSP)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var List = from a in EFashionDB.shop_chamdiems
                       where a.MaSanPham == MaSP
                       select a;
            return List.ToList();
        }

        public void ThemDiemChoSP(shop_chamdiem NewRecord)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            EFashionDB.shop_chamdiems.InsertOnSubmit(NewRecord);

            try
            {
                EFashionDB.SubmitChanges();
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
            }

        }

      
        //public void CapNhatSP(shop_loaisanpham a)
        //{

        //    EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
        //    shop_loaisanpham select = EFashionDB.shop_loaisanphams.Single(c => c.MaLoaiSanPham == a.MaLoaiSanPham);
        //    if (select != null)
        //        select = a;
        //    EFashionDB.SubmitChanges();
        //}

        ///////////////////////////////////////////////////////////////////
    }
}
